package com.smart.community.commons.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * Nacos配置中心客户端配置类
 * 
 * @author Wu.Liang
 * @date 2024-12-19
 */
@Configuration
@Slf4j
public class NacosConfig {
    
    @Value("${spring.cloud.nacos.discovery.server-addr:unknown}")
    private String nacosServerAddr;
    
    @Value("${spring.cloud.nacos.discovery.namespace:dev}")
    private String namespace;
    
    @Value("${spring.cloud.nacos.discovery.group:DEFAULT_GROUP}")
    private String group;
    
    @Value("${spring.application.name:unknown}")
    private String applicationName;
    
    @Value("${server.port:8080}")
    private String serverPort;
    
    /**
     * 初始化Nacos配置信息
     */
    @PostConstruct
    public void init() {
        log.info("=== Nacos客户端配置初始化 ===");
        log.info("Nacos地址: {}", nacosServerAddr);
        log.info("命名空间: {}", namespace);
        log.info("分组名称: {}", group);
        log.info("服务名称: {}", applicationName);
        log.info("服务端口: {}", serverPort);
        log.info("服务注册地址: http://127.0.0.1:{}", serverPort);
        log.info("健康检查配置: 启用");
        log.info("心跳间隔: 5秒");
        log.info("配置热更新: 启用");
        log.info("================================");
    }
}
